<style>
    .edui-editor {
        z-index: 0 !important;
    }

    .edui1_iframeholder {
        z-index: 0 !important;
    }
</style>
<!-- 配置文件 -->
<script type="text/javascript" src="{{ asset('ueditor/ueditor.config.js') }}"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="{{ asset('ueditor/ueditor.all.js') }}"></script>
<!-- 知网弹窗 -->
<script type="text/javascript" src="{{ asset('ueditor/zhiwangDialog.js') }}"></script>
<!-- word转html -->
<script type="text/javascript" src="{{ asset('ueditor/wordtohtmlDialog.js') }}"></script>
<!-- 插入广告 -->
<script type="text/javascript" src="{{ asset('ueditor/bannerDialog.js') }}"></script>
<script>
    window.UEDITOR_CONFIG.serverUrl = '{{ config('ueditor.route.name') }}'
</script><!-- 实例化编辑器 -->
<script type="text/javascript">
    layui.use(['jquery'], function () {
        let $ = layui.jquery;
        let data = @json($data ?? null);
        $(".ueditor-container").each(function (i, v) {
            let _this = $(this);
            let containerName = _this.attr('id');
            let ueditorContainer = $("#" + containerName);
            if (ueditorContainer != undefined) {
                let ueditor = UE.getEditor(containerName, {permissionCode: "{{ $permission_code ?? "" }}"});
                ueditor.ready(function () {
                    ueditor.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
                    if (data != null) {
                        UE.getEditor(containerName).setContent('')
                        UE.getEditor(containerName).execCommand('insertHtml', data[containerName], true)
                    }
                })
            }
        })
        var container = $("#container");
        if (container.length > 0) {
            var ue = UE.getEditor('container');
            ue.ready(function () {
                ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
            });
        }
    })
</script>
